#to process the science image after the bias and flat correction have been finished.
#to process all the image in the current directory.
rm -rf /tmp/*
date >>xtime

DIR_data=$1

if [ $# -ne 1  ]
then
	echo "usage: xauto_60cm.sh /home/gwac/data/aaaa "
	exit 0
fi

echo $DIR_data

cd $DIR_data
rm -rf *c.fit
rm -rf results
ls *.fit | grep -v "Zero" | grep -v "Flat" >listforprocess

xstackimg.sh listforprocess

cd $DIR_data
ls *_c.fit >listlimit
if test ! -s listlimit
then
	echo `pwd` 
	echo "No any combined image exit!"
	exit 0
else
	cd $DIR_data
	xlimit_list.sh listlimit
	
	cd $DIR_data
	xfindglade_list.sh listlimit
	wait
#	for fitfile in `cat listlimit`
#	do
#		echo $fitfile
#		findglade $fitfile
#	done
#		
#	cd $DIR_data
#	xfindgalaxy_list.sh listlimit
	cd $DIR_data
	xot_list.sh listlimit
	
	echo "Data process is over for all the images"
	
	rm -rf listlimit listforprocess
fi

date >>xtime
